#include "stdafx.h"
#include "AIFAXml.h"


CAIFAXml::CAIFAXml()
{

}

CAIFAXml::~CAIFAXml()
{

}


void CAIFAXml::SetFile(CString strFile)
{
	m_strFile = strFile;
}

void CAIFAXml::SetMs(CString strMs)
{
	m_strMs = strMs;
}

CString CAIFAXml::GetMs()
{
	return m_strMs;
}
//bool CAIFAXml::ReadFile()
//{
//	CMarkup xml;
//
//	if (!xml.Load(m_strFile)) return false;
//	CString strTemp;
//
//	xml.ResetPos();
//	xml.FindElem();
//
//	strTemp = xml.GetAttrib(_T("ver"));
//
//	m_nVersion = _ttoi(strTemp);
//	//m_nTotolStep 
//
//	return true;
//	
//}

bool CAIFAXml::ReadFileV141(vector<CALStep*>& list)
{
	CMarkup xml;
	
	if (!xml.Load(m_strFile)) return false;
	CString strTemp;
	
	xml.ResetPos();
	xml.FindElem();

	strTemp = xml.GetAttrib(_T("ver_1"));
	m_nVersion[0] = _ttoi(strTemp);

	strTemp = xml.GetAttrib(_T("ver_2"));
	m_nVersion[1] = _ttoi(strTemp);

	strTemp = xml.GetAttrib(_T("ver_3"));
	m_nVersion[2] = _ttoi(strTemp);

	xml.IntoElem();

		xml.FindElem(_T("alinfo"));
		m_strMs = xml.GetData();

		xml.FindElem(_T("alsteps"));
		strTemp = xml.GetAttrib(_T("num"));

		int nTotolStep = _ttoi(strTemp);

		if (nTotolStep != 0)
		{
			xml.IntoElem();

			m_nCurStep = 0;
			while (xml.FindElem(_T("alstep")))
			{
				xml.IntoElem();

				CALStep* pStep = new CALStep();
				while (xml.FindElem(_T("alstepitem")))
				{
					strTemp = xml.GetAttrib(_T("type"));
					praseByStepItem(xml, strTemp, pStep);
				}

				list.push_back(pStep);

				m_nCurStep++;
				xml.OutOfElem();
			}

			xml.OutOfElem();
		}


	xml.OutOfElem();

	return true;
}


void CAIFAXml::praseByStepItem(CMarkup xml, CString strType, CALStep* pStep)
{
	CString strTemp;

	if (strType == _T("emal_b_read"))
	{
		CALSIBRead* pObject = new CALSIBRead();

		xml.IntoElem();

		if (xml.FindElem(_T("filename")))
		{
			strTemp = xml.GetData();

			USES_CONVERSION;
			pObject->SetItemFileName(T2A(strTemp));
		}

		if (xml.FindElem(_T("filename2")))
		{
			strTemp = xml.GetData();

			USES_CONVERSION;
			pObject->SetItemFileName2(T2A(strTemp));
		}

		if (xml.FindElem(_T("ms")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMs(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_write"))
	{
		CALSIBWrite* pObject = new CALSIBWrite();

		xml.IntoElem();

		if (xml.FindElem(_T("filename")))
		{
			strTemp = xml.GetData();

			USES_CONVERSION;
			pObject->SetItemFileName(T2A(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	///////////////////////////////////////////////////////
	else if (strType == _T("emal_b_blur"))
	{
		CALSIBBlur* pObject = new CALSIBBlur();

		xml.IntoElem();

		if (xml.FindElem(_T("fs")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFs(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("para0")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(0, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para1")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(1, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para2")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(2, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para3")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(3, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para4")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(4, _ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_brightness"))
	{
		CALSIBBrightness* pObject = new CALSIBBrightness();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_channel"))
	{
		CALSIBChannel* pObject = new CALSIBChannel();

		xml.IntoElem();

		if (xml.FindElem(_T("fs")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFs(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("para0")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(0, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para1")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(1, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para2")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(2, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para3")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(3, _ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_color"))
	{
		CALSIBColor* pObject = new CALSIBColor();

		xml.IntoElem();

		if (xml.FindElem(_T("fs")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFs(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("ms")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMs(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_cut"))
	{
		CALSIBCut* pObject = new CALSIBCut();

		xml.IntoElem();

		if (xml.FindElem(_T("poinx")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPointX(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("poiny")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPointY(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("width")))
		{
			strTemp = xml.GetData();
			pObject->SetItemWidth(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("height")))
		{
			strTemp = xml.GetData();
			pObject->SetItemHeight(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_split"))
	{
		CALSIBSplit* pObject = new CALSIBSplit();

		xml.IntoElem();

		if (xml.FindElem(_T("x")))
		{
			strTemp = xml.GetData();
			pObject->SetItemX(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("y")))
		{
			strTemp = xml.GetData();
			pObject->SetItemY(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_b_threshold"))
	{
		CALSIBThreshold* pObject = new CALSIBThreshold();

		xml.IntoElem();

		if (xml.FindElem(_T("fs")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFs(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("para0")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(0, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para1")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(1, _ttoi(strTemp));
		}

		if (xml.FindElem(_T("para2")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPara(2, _ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	/////////////////////////////////////////////////////
	else if (strType == _T("emal_e_canny"))
	{
		CALSIECanny* pObject = new CALSIECanny();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_dog"))
	{
		CALSIEDoG* pObject = new CALSIEDoG();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_hog"))
	{
		CALSIEHoG* pObject = new CALSIEHoG();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_kirsch"))
	{
		CALSIEKirsch* pObject = new CALSIEKirsch();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_log"))
	{
		CALSIELoG* pObject = new CALSIELoG();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_prewitt"))
	{
		CALSIEPrewitt* pObject = new CALSIEPrewitt();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_robert"))
	{
		CALSIERobert* pObject = new CALSIERobert();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_e_robert"))
	{
		CALSIESobel* pObject = new CALSIESobel();

		pStep->AddItem((CALStepItem*)pObject);
	}
	///////////////////////////////////////////
	else if (strType == _T("emal_o_blob"))
	{
		CALSIOBlob* pObject = new CALSIOBlob();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_histogram"))
	{
		CALSIOHistogram* pObject = new CALSIOHistogram();

		xml.IntoElem();

		if (xml.FindElem(_T("fs")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFs(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_lbp"))
	{
		CALSIOLBP* pObject = new CALSIOLBP();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_mse"))
	{
		CALSIOMSE* pObject = new CALSIOMSE();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_psnr"))
	{
		CALSIOPSNR* pObject = new CALSIOPSNR();

		xml.IntoElem();

		if (xml.FindElem(_T("num")))
		{
			strTemp = xml.GetData();
			pObject->SetItemNum(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_sad"))
	{
		CALSIOSAD* pObject = new CALSIOSAD();

		xml.IntoElem();

		if (xml.FindElem(_T("size")))
		{
			strTemp = xml.GetData();
			pObject->SetItemSize(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("dsr")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDSR(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_scharr"))
	{
		CALSIOScharr* pObject = new CALSIOScharr();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_sgbm"))
	{
		CALSIOSGBM* pObject = new CALSIOSGBM();

		xml.IntoElem();

		if (xml.FindElem(_T("view")))
		{
			strTemp = xml.GetData();
			pObject->SetItemView(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_siff"))
	{
		CALSIOSIFF* pObject = new CALSIOSIFF();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_ssim"))
	{
		CALSIOSSIM* pObject = new CALSIOSSIM();

		xml.IntoElem();

		if (xml.FindElem(_T("num")))
		{
			strTemp = xml.GetData();
			pObject->SetItemNum(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_o_svm"))
	{
		CALSIOSVM* pObject = new CALSIOSVM();

		pStep->AddItem((CALStepItem*)pObject);
	}
	////////////////////////////////////////////////
	else if (strType == _T("emal_p_agast"))
	{
		CALSIPAGAST* pObject = new CALSIPAGAST();

		xml.IntoElem();

		if (xml.FindElem(_T("threshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemThreshold(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("nonmaxsuppression")))
		{
			strTemp = xml.GetData();
			pObject->SetItemNonmaxSuppression(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("type")))
		{
			strTemp = xml.GetData();
			pObject->SetItemType(_ttoi(strTemp));
		}

		xml.OutOfElem();


		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_akaze"))
	{
		CALSIPAKAZE* pObject = new CALSIPAKAZE();

		xml.IntoElem();

		if (xml.FindElem(_T("descriptortype")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDescriptorType(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("descriptorsize")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDescriptorSize(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("descriptorchannels")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDescriptorChannels(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("threshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemThreshold(_tstof(strTemp));
		}

		if (xml.FindElem(_T("octaves")))
		{
			strTemp = xml.GetData();
			pObject->SetItemOctaves(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("octavelayers")))
		{
			strTemp = xml.GetData();
			pObject->SetItemOctaveLayers(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("diffusivity")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDiffusivity(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_bob"))
	{
		CALSIPBob* pObject = new CALSIPBob();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_brisk"))
	{
		CALSIPBRISK* pObject = new CALSIPBRISK();

		xml.IntoElem();

		if (xml.FindElem(_T("threshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemThreshold(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("octaves")))
		{
			strTemp = xml.GetData();
			pObject->SetItemOctaves(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("patternScale")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPatternScale(_tstof(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_fast"))
	{
		CALSIPFAST* pObject = new CALSIPFAST();

		xml.IntoElem();

		if (xml.FindElem(_T("threshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemThreshold(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("nonmaxsuppression")))
		{
			strTemp = xml.GetData();
			pObject->SetItemNonmaxSuppression(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("type")))
		{
			strTemp = xml.GetData();
			pObject->SetItemType(_tstof(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_gftt"))
	{
		CALSIPGFTT* pObject = new CALSIPGFTT();

		xml.IntoElem();

		if (xml.FindElem(_T("maxcorners")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMaxCorners(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("qualitylevel")))
		{
			strTemp = xml.GetData();
			pObject->SetItemQualityLevel(_tstof(strTemp));
		}

		if (xml.FindElem(_T("mindistance")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMinDistance(_tstof(strTemp));
		}

		if (xml.FindElem(_T("blocksize")))
		{
			strTemp = xml.GetData();
			pObject->SetItemBlockSize(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("useharrisdetector")))
		{
			strTemp = xml.GetData();
			pObject->SetItemUseHarrisDetector(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("k")))
		{
			strTemp = xml.GetData();
			pObject->SetItemK(_tstof(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_glcm"))
	{
		CALSIPGLCM* pObject = new CALSIPGLCM();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_kaze"))
	{
		CALSIPKAZE* pObject = new CALSIPKAZE();

		xml.IntoElem();

		if (xml.FindElem(_T("extended")))
		{
			strTemp = xml.GetData();
			pObject->SetItemExtended(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("upright")))
		{
			strTemp = xml.GetData();
			pObject->SetItemUpright(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("threshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemThreshold(_tstof(strTemp));
		}

		if (xml.FindElem(_T("octaves")))
		{
			strTemp = xml.GetData();
			pObject->SetItemOctaves(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("octavelayers")))
		{
			strTemp = xml.GetData();
			pObject->SetItemOctaveLayers(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("diffusivity")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDiffusivity(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_mser"))
	{
		CALSIPMSER* pObject = new CALSIPMSER();

		xml.IntoElem();

		if (xml.FindElem(_T("delta")))
		{
			strTemp = xml.GetData();
			pObject->SetItemDelta(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("minarea")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMinArea(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("maxarea")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMaxArea(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("maxvariation")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMaxVariation(_tstof(strTemp));
		}

		if (xml.FindElem(_T("mindiversity")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMinDiversity(_tstof(strTemp));
		}

		if (xml.FindElem(_T("maxevolution")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMaxEvolution(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("areathreshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemAreaThreshold(_tstof(strTemp));
		}

		if (xml.FindElem(_T("minmargin")))
		{
			strTemp = xml.GetData();
			pObject->SetItemMinMargin(_tstof(strTemp));
		}

		if (xml.FindElem(_T("edgeblursize")))
		{
			strTemp = xml.GetData();
			pObject->SetItemEdgeBlurSize(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_orb"))
	{
		CALSIPORB* pObject = new CALSIPORB();

		xml.IntoElem();

		if (xml.FindElem(_T("features")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFeatures(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("scalefactor")))
		{
			strTemp = xml.GetData();
			pObject->SetItemScaleFactor(_tstof(strTemp));
		}

		if (xml.FindElem(_T("levels")))
		{
			strTemp = xml.GetData();
			pObject->SetItemLevels(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("edgethreshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemEdgeThreshold(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("firstlevel")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFirstLevel(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("WTA_K")))
		{
			strTemp = xml.GetData();
			pObject->SetItemWTA_K(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("WTA_K")))
		{
			strTemp = xml.GetData();
			pObject->SetItemWTA_K(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("scoretype")))
		{
			strTemp = xml.GetData();
			pObject->SetItemScoreType(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("patchsize")))
		{
			strTemp = xml.GetData();
			pObject->SetItemPatchSize(_ttoi(strTemp));
		}

		if (xml.FindElem(_T("fastthreshold")))
		{
			strTemp = xml.GetData();
			pObject->SetItemFastThreshold(_ttoi(strTemp));
		}

		xml.OutOfElem();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_star"))
	{
		CALSIPSTAR* pObject = new CALSIPSTAR();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_p_surf"))
	{
		CALSIPSURF* pObject = new CALSIPSURF();

		pStep->AddItem((CALStepItem*)pObject);
	}
	////////////////////////////////////////////
	else if (strType == _T("emal_s_ac"))
	{
		CALSISAC* pObject = new CALSISAC();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_bms"))
	{
		CALSISBMS* pObject = new CALSISBMS();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_ft"))
	{
		CALSISFT* pObject = new CALSISFT();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_gmr"))
	{
		CALSISGMR* pObject = new CALSISGMR();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_hc"))
	{
		CALSISHC* pObject = new CALSISHC();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_itti"))
	{
		CALSISITTI* pObject = new CALSISITTI();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_lc"))
	{
		CALSISLC* pObject = new CALSISLC();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_mbp"))
	{
		CALSISMBP* pObject = new CALSISMBP();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_mss"))
	{
		CALSISMSS* pObject = new CALSISMSS();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_phot"))
	{
		CALSISPHOT* pObject = new CALSISPHOT();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_rc"))
	{
		CALSISRC* pObject = new CALSISRC();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_rudinac"))
	{
		CALSISRudinac* pObject = new CALSISRudinac();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_sf"))
	{
		CALSISSF* pObject = new CALSISSF();

		pStep->AddItem((CALStepItem*)pObject);
	}
	else if (strType == _T("emal_s_sr"))
	{
		CALSISSR* pObject = new CALSISSR();

		pStep->AddItem((CALStepItem*)pObject);
	}
}

bool CAIFAXml::WriteFileV141(vector<CALStep*> list)
{
	if (FindFile(m_strFile))
	{
		RemoveXML(m_strFile);
	}

	int nTotolStep = list.size();

	String strStd;
	CString strTemp;

	CMarkup xml;
	xml.SetDoc(_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
	xml.AddElem(_T("alprocess"));
	xml.AddAttrib(_T("ver_1"), 1);
	xml.AddAttrib(_T("ver_2"), 4);
	xml.AddAttrib(_T("ver_3"), 1);
	xml.IntoElem();
		
		xml.AddElem(_T("alinfo"), m_strMs);

		xml.AddElem(_T("alsteps"));
		xml.AddAttrib(_T("num"), nTotolStep);
		xml.IntoElem();
			
			for (int i = 0; i < nTotolStep; i++)
			{
				xml.AddElem(_T("alstep"));
				xml.IntoElem();

				CALStep* pTempStep = list[i];
				const ALStepItemVector& list = pTempStep->GetItemlist();
				CALStepItemIt it = list.begin();
				for (; it != list.end(); it++)
				{
					CALStepItem* pStepItem = *it;

					createByStepItem(xml, pStepItem);
				}
				
				xml.OutOfElem();
			}


		xml.OutOfElem();

	xml.OutOfElem();
	xml.Save(m_strFile);

	return true;
}

void CAIFAXml::createByStepItem(CMarkup& xml, CALStepItem* pStepItem)
{
	String strStd;
	CString strTemp;

	EMALType nType = pStepItem->GetItemId();

	switch (nType)
	{
		case EM_AL_BRead:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBRead* pObject = (CALSIBRead*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_read"));
			xml.IntoElem();

			strStd = pObject->GetItemFileName();
			strTemp = (CString)strStd.c_str();
			xml.AddElem(_T("filename"), strTemp);

			strStd = pObject->GetItemFileName2();
			strTemp = (CString)strStd.c_str();
			xml.AddElem(_T("filename2"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemMs());
			xml.AddElem(_T("ms"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BWrite:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBWrite* pObject = (CALSIBWrite*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_write"));
			xml.IntoElem();

			strStd = pObject->GetItemFileName();
			strTemp = (CString)strStd.c_str();
			xml.AddElem(_T("filename"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BBlur:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBBlur* pObject = (CALSIBBlur*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_blur"));
			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemFs());
			xml.AddElem(_T("fs"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(0));
			xml.AddElem(_T("para0"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(1));
			xml.AddElem(_T("para1"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(2));
			xml.AddElem(_T("para2"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(3));
			xml.AddElem(_T("para3"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(4));
			xml.AddElem(_T("para4"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BBrightness:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBBrightness* pObject = (CALSIBBrightness*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_b_brightness"));
		}
		break;
		case EM_AL_BChannel:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBChannel* pObject = (CALSIBChannel*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_channel"));
			xml.IntoElem();

				strTemp.Format(_T("%d"), pObject->GetItemFs());
				xml.AddElem(_T("fs"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemPara(0));
				xml.AddElem(_T("para0"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemPara(1));
				xml.AddElem(_T("para1"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemPara(2));
				xml.AddElem(_T("para2"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemPara(3));
				xml.AddElem(_T("para3"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BColor:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBColor* pObject = (CALSIBColor*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_color"));
			xml.IntoElem();

				strTemp.Format(_T("%d"), pObject->GetItemFs());
				xml.AddElem(_T("fs"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemMs());
				xml.AddElem(_T("ms"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BCut:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBCut* pObject = (CALSIBCut*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_b_cut"));
			
			xml.IntoElem();

				strTemp.Format(_T("%d"), pObject->GetItemPointX());
				xml.AddElem(_T("ponitx"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemPointY());
				xml.AddElem(_T("ponity"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemWidth());
				xml.AddElem(_T("width"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemHeight());
				xml.AddElem(_T("height"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BSplit:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBSplit* pObject = (CALSIBSplit*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_b_split"));

			xml.IntoElem();

				strTemp.Format(_T("%d"), pObject->GetItemX());
				xml.AddElem(_T("x"), strTemp);

				strTemp.Format(_T("%d"), pObject->GetItemY());
				xml.AddElem(_T("y"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_BThreshold:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIBThreshold* pObject = (CALSIBThreshold*)pStepItem;
			xml.AddAttrib(_T("type"), _T("emal_b_threshold"));
			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemFs());
			xml.AddElem(_T("fs"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(0));
			xml.AddElem(_T("para0"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(1));
			xml.AddElem(_T("para1"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPara(2));
			xml.AddElem(_T("para2"), strTemp);

			xml.OutOfElem();
		}
		break;
		//////////////////////////////////////////	
		case EM_AL_ECanny:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIECanny* pObject = (CALSIECanny*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_canny"));
		}
		break;
		case EM_AL_EDoG:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIEDoG* pObject = (CALSIEDoG*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_dog"));
		}
		break;
		case EM_AL_EHoG:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIEHoG* pObject = (CALSIEHoG*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_hog"));
		}
		break;
		case EM_AL_EKirsch:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIEKirsch* pObject = (CALSIEKirsch*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_kirsch"));
		}
		break;
		case EM_AL_ELaplacian:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIELaplacian* pObject = (CALSIELaplacian*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_laplacian"));
		}
		break;
		case EM_AL_ELoG:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIELoG* pObject = (CALSIELoG*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_log"));
		}
		break;
		case EM_AL_EPrewitt:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIEPrewitt* pObject = (CALSIEPrewitt*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_prewitt"));
		}
		break;
		case EM_AL_ERobert:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIERobert* pObject = (CALSIERobert*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_robert"));
		}
		break;
		case EM_AL_ESobel:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIESobel* pObject = (CALSIESobel*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_e_sobel"));
		}
		break;
		/////////////////////////////////////////////////////////
		case EM_AL_OBlob:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOBlob* pObject = (CALSIOBlob*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_blob"));
		}
		break;
		case EM_AL_OHistogram:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOHistogram* pObject = (CALSIOHistogram*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_histogram"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemFs());
			xml.AddElem(_T("fs"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_OLBP:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOLBP* pObject = (CALSIOLBP*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_lbp"));
		}
		break;
		case EM_AL_OMSE:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOMSE* pObject = (CALSIOMSE*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_mse"));
		}
		break;
		case EM_AL_OPSNR:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOPSNR* pObject = (CALSIOPSNR*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_psnr"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemNum());
			xml.AddElem(_T("num"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_OSAD:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOSAD* pObject = (CALSIOSAD*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_sad"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemSize());
			xml.AddElem(_T("size"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemDSR());
			xml.AddElem(_T("dsr"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_OScharr:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOScharr* pObject = (CALSIOScharr*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_scharr"));
		}
		break;
		case EM_AL_OSGBM:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOSGBM* pObject = (CALSIOSGBM*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_sgbm"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemView());
			xml.AddElem(_T("view"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_OSIFF:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOSIFF* pObject = (CALSIOSIFF*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_siff"));
		}
		break;
		case EM_AL_OSSIM:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOSSIM* pObject = (CALSIOSSIM*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_ssim"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemNum());
			xml.AddElem(_T("num"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_OSVM:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIOSVM* pObject = (CALSIOSVM*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_o_svm"));
		}
		break;
		//////////////////////////////////////////////////
		case EM_AL_PAGAST:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPAGAST* pObject = (CALSIPAGAST*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_agast"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemThreshold());
			xml.AddElem(_T("threshold"), strTemp);

			if (pObject->GetItemNonmaxSuppression())
			{
				xml.AddElem(_T("nonmaxsuppression"), _T("1"));
			}
			else
			{
				xml.AddElem(_T("nonmaxsuppression"), _T("0"));
			}		

			strTemp.Format(_T("%d"), pObject->GetItemType());
			xml.AddElem(_T("type"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PAKAZE:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPAKAZE* pObject = (CALSIPAKAZE*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_akaze"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemDescriptorType());
			xml.AddElem(_T("descriptortype"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemDescriptorSize());
			xml.AddElem(_T("descriptorsize"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemDescriptorChannels());
			xml.AddElem(_T("descriptorchannels"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemThreshold());
			xml.AddElem(_T("threshold"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemOctaves());
			xml.AddElem(_T("octaves"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemOctaveLayers());
			xml.AddElem(_T("octavelayers"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemDiffusivity());
			xml.AddElem(_T("diffusivity"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PBob:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPBob* pObject = (CALSIPBob*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_bob"));
		}
		break;
		case EM_AL_PBRISK:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPBRISK* pObject = (CALSIPBRISK*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_brisk"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemThreshold());
			xml.AddElem(_T("threshold"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemOctaves());
			xml.AddElem(_T("octaves"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemPatternScale());
			xml.AddElem(_T("patternscale"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PFAST:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPFAST* pObject = (CALSIPFAST*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_fast"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemThreshold());
			xml.AddElem(_T("threshold"), strTemp);
			
			if (pObject->GetItemNonmaxSuppression())
			{
				xml.AddElem(_T("nonmaxsuppression"), _T("1"));
			}
			else
			{
				xml.AddElem(_T("nonmaxsuppression"), _T("0"));
			}
			
			strTemp.Format(_T("%d"), pObject->GetItemType());
			xml.AddElem(_T("type"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PGFTT:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPGFTT* pObject = (CALSIPGFTT*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_gftt"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemMaxCorners());
			xml.AddElem(_T("maxcorners"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemQualityLevel());
			xml.AddElem(_T("qualitylevel"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemMinDistance());
			xml.AddElem(_T("mindistance"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemBlockSize());
			xml.AddElem(_T("blocksize"), strTemp);

			if (pObject->GetItemUseHarrisDetector())
			{
				xml.AddElem(_T("useharrisdetector"), _T("1"));
			}
			else
			{
				xml.AddElem(_T("useharrisdetector"), _T("0"));
			}

			strTemp.Format(_T("%f"), pObject->GetItemK());
			xml.AddElem(_T("k"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PGLCM:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPGLCM* pObject = (CALSIPGLCM*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_glcm"));
		}
		break;
		case EM_AL_PKAZE:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPKAZE* pObject = (CALSIPKAZE*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_kaze"));

			xml.IntoElem();

			if (pObject->GetItemExtended())
			{
				xml.AddElem(_T("extended"), _T("1"));
			}
			else
			{
				xml.AddElem(_T("extended"), _T("0"));
			}

			if (pObject->GetItemUpright())
			{
				xml.AddElem(_T("upright"), _T("1"));
			}
			else
			{
				xml.AddElem(_T("upright"), _T("0"));
			}

			strTemp.Format(_T("%f"), pObject->GetItemThreshold());
			xml.AddElem(_T("threshold"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemOctaves());
			xml.AddElem(_T("octaves"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemOctaveLayers());
			xml.AddElem(_T("octavelayers"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemDiffusivity());
			xml.AddElem(_T("diffusivity"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PMSER:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPMSER* pObject = (CALSIPMSER*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_mesr"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemDelta());
			xml.AddElem(_T("delta"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemMinArea());
			xml.AddElem(_T("minarea"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemMaxArea());
			xml.AddElem(_T("maxarea"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemMaxVariation());
			xml.AddElem(_T("maxvariation"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemMinDiversity());
			xml.AddElem(_T("mindiversity"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemMaxEvolution());
			xml.AddElem(_T("maxevolution"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemAreaThreshold());
			xml.AddElem(_T("areathreshold"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemMinMargin());
			xml.AddElem(_T("minmargin"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemEdgeBlurSize());
			xml.AddElem(_T("edgeblursize"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PORB:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPORB* pObject = (CALSIPORB*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_orb"));

			xml.IntoElem();

			strTemp.Format(_T("%d"), pObject->GetItemFeatures());
			xml.AddElem(_T("features"), strTemp);

			strTemp.Format(_T("%f"), pObject->GetItemScaleFactor());
			xml.AddElem(_T("scalefactor"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemLevels());
			xml.AddElem(_T("levels"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemEdgeThreshold());
			xml.AddElem(_T("edgethreshold"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemFirstLevel());
			xml.AddElem(_T("firstlevel"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemWTA_K());
			xml.AddElem(_T("WTA_K"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemScoreType());
			xml.AddElem(_T("scoretype"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemPatchSize());
			xml.AddElem(_T("patchsize"), strTemp);

			strTemp.Format(_T("%d"), pObject->GetItemFastThreshold());
			xml.AddElem(_T("fastthreshold"), strTemp);

			xml.OutOfElem();
		}
		break;
		case EM_AL_PSTAR:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPSTAR* pObject = (CALSIPSTAR*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_star"));
		}
		break;
		case EM_AL_PSURF:
		{
			xml.AddElem(_T("alstepitem"));
			CALSIPSURF* pObject = (CALSIPSURF*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_p_surf"));
		}
		break;
		/////////////////////////////////////////////////////////
		case EM_AL_SAC:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISAC* pObject = (CALSISAC*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_ac"));
		}
		break;
		case EM_AL_SBMS:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISBMS* pObject = (CALSISBMS*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_bms"));
		}
		break;
		case EM_AL_SFT:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISFT* pObject = (CALSISFT*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_ft"));
		}
		break;
		case EM_AL_SGMR:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISGMR* pObject = (CALSISGMR*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_gmr"));
		}
		break;
		case EM_AL_SHC:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISHC* pObject = (CALSISHC*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_hc"));
		}
		break;
		case EM_AL_SITTI:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISITTI* pObject = (CALSISITTI*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_itti"));
		}
		break;
		case EM_AL_SLC:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISLC* pObject = (CALSISLC*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_lc"));
		}
		break;
		case EM_AL_SMBP:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISMBP* pObject = (CALSISMBP*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_mbp"));
		}
		break;
		case EM_AL_SMSS:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISMSS* pObject = (CALSISMSS*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_mss"));
		}
		break;
		case EM_AL_SPHOT:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISPHOT* pObject = (CALSISPHOT*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_phot"));
		}
		break;
		case EM_AL_SRC:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISRC* pObject = (CALSISRC*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_rc"));
		}
		break;
		case EM_AL_SRudinac:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISRudinac* pObject = (CALSISRudinac*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_rudinac"));
		}
		break;
		case EM_AL_SSF:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISSF* pObject = (CALSISSF*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_sf"));
		}
		break;
		case EM_AL_SSR:
		{
			xml.AddElem(_T("alstepitem"));
			CALSISSR* pObject = (CALSISSR*)pStepItem;

			xml.AddAttrib(_T("type"), _T("emal_s_sr"));
		}
		break;
		/////////////////////////////////////////////////////////
		default:break;
	}
}

bool CAIFAXml::FindFile(LPCTSTR file)
{
	CFileFind finder;
	bool bWorking = finder.FindFile(file);
	finder.Close();
	return bWorking;
}

void CAIFAXml::RemoveXML(LPCTSTR file)
{
	try
	{
		CFile::Remove(file);
	}
	catch (CFileException* pEx)
	{
		TRACE(_T("File %20s cannot be removed\n"), file);
		pEx->Delete();
	}
}

